﻿<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Detail.aspx.cs" ValidateRequest="false"
    Inherits="LabMS.Web.Post.BBS.Detail" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>在线交流 - 帖子详情</title>
    <link type="text/css" rel="stylesheet" href="../../style/screen.css" />
    <link href="../../style/post.css" rel="stylesheet" type="text/css" />
    <!--[if lte IE 6]>
    <link type="text/css" rel="stylesheet" href="../../style/ie6.css" />
    <![endif]-->
    <!--[if lte IE 7]>
    <link type="text/css" rel="stylesheet" href="../../style/ie7.css" />
    <![endif]-->
</head>
<body class="mainBody">
    <form id="uiForm" runat="server">
        <div class="main">
            <div id="pageInfo" class="clearfix">
                <div class="title">
                    <label>
                        <a href="Index.aspx">在线交流</a></label>
                    &gt;
                    <label>
                        <a href="javascript:;">所属分区</a></label>
                    &gt;
                    <label>
                        <a href="javascript:;">所属版块</a></label>
                </div>
            </div>
        </div>
        <% if (post == null) return; %>
        <div class="main">
            <div class="postReplyContainer">
                <div class="postReplyHeader">
                    主题:
                    <%= post.PostTitle %>
                </div>
                <div class="postReply">
                    <div class="postReplyTitle clearfix">
                        <div class="postReplyAuthorInfo">
                            <%
                                ExtendBLL.Post p = new ExtendBLL.Post();
                                string authorName = p.GetAuthorName(post.PosterID.Value, post.PosterType.ToString());
                            %>
                            <%= p.GetAuthorNamePrefix(post.PosterType.ToString()) %>
                            <%= string.IsNullOrEmpty(authorName) ? "<del>已删除用户</del>" : authorName %>
                            发表于
                            <%= post.PostRecordTime.Value.ToString("yy-MM-dd HH:mm") %>
                        </div>
                        <div class="postReplyAction">
                            楼主
                        </div>
                    </div>
                    <div class="postReplyContent">
                        <%= Server.HtmlDecode(post.PostContent) %>
                    </div>
                </div>
                <%
                    for (int i = 0; i < dsReplies.Tables[0].Rows.Count; i++)
                    {
                        System.Data.DataRow row = dsReplies.Tables[0].Rows[i];
                %>
                <div class="postReply">
                    <div class="postReplyTitle clearfix">
                        <div class="postReplyAuthorInfo">
                            <%= p.GetAuthorNamePrefix(row["ReplierType"].ToString()) %>
                            <%= row["ReplierName"].ToString()%>
                            回复于
                            <%= row["PostReplyTime"].ToString()%>
                        </div>
                        <div class="postReplyAction">
                            <input type="hidden" value='<%= row["ID"] %>' />
                            第
                            <%= row["PostReplySN"].ToString()%>
                            贴
                            <% 
                                bool authorized = base.UserType.Equals("mana") && base.HavePrivilege("ZTGL");
                                if (UserType.Equals("mana") && authorized)
                                { %>
                            <a href="javascript:;">删除</a>
                            <%} %>
                        </div>
                    </div>
                    <div class="postReplyContent">
                        <%= Server.HtmlDecode(row["PostReplyContent"].ToString()) %>
                    </div>
                </div>
                <%} %>
                <webdiyer:AspNetPager ID="AspNetPager" PageSize="10" runat="server" UrlPaging="False"
                    FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" OnPageChanged="AspNetPager_PageChanged"
                    PrevPageText="上一页" Direction="LeftToRight" HorizontalAlign="Right" Wrap="False">
                </webdiyer:AspNetPager>
            </div>
            <div class="postReplyUI">
                回复:<table cellpadding="5" cellspacing="0">
                    <tr>
                        <td>
                            <asp:TextBox ID="ReplyNew" TextMode="MultiLine" Columns="80" Rows="15" ToolTip="回复主题 - 非空,长度为1到500之间"
                                runat="server"></asp:TextBox></td>
                        <td valign="bottom">
                            <asp:Button ID="BtnReply" runat="server" Text="回复" CssClass="button" OnClick="BtnReply_Click" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </form>

    <script type="text/javascript" src="../../js/jQuery/jquery-1.3.1.js"></script>

    <script type="text/javascript" src="../../js/jQuery/jquery.tooltip.js"></script>

    <script type="text/javascript" src="../../js/jQuery/jquery.validate.js"></script>

    <script type="text/javascript" src="../../fckeditor/fckeditor.js"></script>

    <script type="text/javascript" src="../../js/site.js"></script>

    <script type="text/javascript">

        $(function(){
            $("#uiForm").validate({
                rules: {
                    ReplyNew: {
                        required: true,
                        maxlength: 500
                    }
                },
                messages: {
                    ReplyNew: {
                        required: "回复内容不能为空",
                        maxlength: "回复长度不能超过500"
                    }
                }
            });

            var oFCKeditor = new FCKeditor('ReplyNew', 600, 300, 'BBS');
            oFCKeditor.ReplaceTextarea();

            $("div.postReplyAction").find("a").click(function(){
                var id = $(this).parent().find("input[type='hidden']").val();

                $.post(
                    "DeleteReply.ashx",
                    "{ID: " + id + "}",
                    function(data, status){
                        if (data.success) {
                            window.location.replace(window.location);
                        }
                    },
                    "json"
                );
            });
        });
    
    </script>

</body>
</html>
